package org.easiermock;

import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Method;

import org.aopalliance.intercept.MethodInvocation;

/**
 * AOP-related utility methods
 */
class AopUtil {
	
	private AopUtil() {
		super();
	}
	
	/**
	 * Creates a MethodInvocation object for the supplied parameters
	 * 
	 * @param thisObject the target object
	 * @param method the target method
	 * @param args the arguments of the method call
	 * @return a MethodInvocation object
	 */
	static MethodInvocation createMethodInvocation(final Object thisObject, 
			final Method method, final Object[] args) {
		MethodInvocation methodInvocation = new MethodInvocation() {

			public Method getMethod() {
				return method;
			}

			public Object[] getArguments() {
				return args;
			}

			public AccessibleObject getStaticPart() {
				throw new UnsupportedOperationException("Not implemented");
			}

			public Object getThis() {
				return thisObject;
			}

			public Object proceed() throws Throwable {
				throw new UnsupportedOperationException("Not implemented");
			}
			
		};
		return methodInvocation;
	}


}
